//
//  DiseaseTypeController.m
//  quickDoctor
//
//  Created by zhaowei on 17/3/10.
//  Copyright © 2017年 SWS. All rights reserved.
//

#import "DiseaseTypeController.h"

@interface DiseaseTypeController ()<UITableViewDataSource,UITableViewDelegate>

@end

static NSString *diseaseCell = @"diseaseCell";
@implementation DiseaseTypeController {
    //疾病类型数组
    NSMutableArray *_typeArray;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI{

    
    NSMutableArray *typeArr = [NSMutableArray arrayWithObjects:@"肿瘤科",@"心血管科",@"血液科",@"神经科",@"骨科", nil];

    _typeArray = typeArr;
    self.title = @"疾病类型";
    //添加tableView
    UITableView *tableView = [[UITableView alloc] init];
    [self.view addSubview:tableView];
    
    tableView.dataSource = self;
    tableView.delegate = self;
    //注册cell
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:diseaseCell];
    
    //下方留空白
    tableView.tableFooterView = [UIView new];
    //约束
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:diseaseCell forIndexPath:indexPath];
    
    
    cell.textLabel.text = _typeArray[indexPath.row];
   
    
    
    return cell;
}

#pragma mark
#pragma mark -代理方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    //pop
    [self.navigationController popViewControllerAnimated:YES];
    
    NSString *str = _typeArray[indexPath.row];
    //通知
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pop" object:self userInfo:@{@"text":str}];
    
}


@end
